/*
 * Copyright 2006 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package java.lang;

public final class Boolean {

  public static Boolean FALSE = new Boolean(false);
  public static Boolean TRUE = new Boolean(true);

  private boolean fValue;

  public Boolean(boolean value) {
    fValue = value;
  }

  public Boolean(String s) {
    this((s != null) && s.equalsIgnoreCase("true"));
  }

  public boolean booleanValue() {
    return fValue;
  }

  public static String toString(boolean x) {
    return String.valueOf(x);
  }

  public int hashCode() {
    return fValue ? 1231 : 1237; // (see the Java API doc)
  }

  public boolean equals(Object o) {
    return (o instanceof Boolean) && (((Boolean) o).fValue == fValue);
  }

  public String toString() {
    return fValue ? "true" : "false";
  }

  public static Boolean valueOf(String s) {
    if (s != null && s.equalsIgnoreCase("true"))
      return TRUE;
    else
      return FALSE;
  }

  public static Boolean valueOf(boolean b) {
    return b ? TRUE : FALSE;
  }
}
